Skip to main content

Unity 3d 后代生成LineRenderer线

var aMaterial:Material;
private var mLine:LineRenderer;
function Start ()
{

mLine = this.gameObject.AddComponent(LineRenderer);
mLine.SetWidth(5, 5);
mLine.SetVertexCount(300);
mLine.SetColors (Color.yellow,Color.yellow);
mLine.material = aMaterial;//材质
mLine.material.color = Color (0, 1, 0, 0.25);
mLine.renderer.enabled = true; //启用
}

var i:int=0;
function Update()
{
if(i<300)
{
mLine.SetPosition(i,Input.mousePosition);//鼠标坐标
}
i++;
}